package com.ruowei.modules.foodOrder.repository;

import com.querydsl.core.BooleanBuilder;
import com.querydsl.core.types.Predicate;
import com.ruowei.common.repository.BaseRepository;
import com.ruowei.modules.foodOrder.domain.Merchant;

import com.ruowei.modules.foodOrder.domain.QMerchant;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.*;
import org.springframework.stereotype.Repository;

import java.util.Collection;
import java.util.Optional;

/**
 * Spring Data  repository for the Merchant entity.
 */
@Repository
public interface MerchantRepository extends BaseRepository<Long, Merchant, QMerchant> {
    Boolean existsByMerchantNameAndStatusIn(String merchantName, Collection<String> status);

    boolean existsByMerchantNameAndStatusNot(String merchantName, String status);

    boolean existsByMerchantNameAndStatusNotAndIdNot(String merchantName, String status, Long id);

    boolean existsByMerchantNameAndIdNot(String merchantName, Long id);

    Optional<Merchant> findByMerchantCode(String merchantCode);

    Optional<Merchant> findOneByMerchantCodeAndStatusNot(String merchantCode, String status);

    Optional<Merchant> findOneByMerchantCodeAndStatus(String merchantCode, String status);

    Optional<Merchant> findOneByMerchantCode(String merchantCode);

    Boolean existsByPhoneAndStatusNot(String phone, String status);

    Optional<Merchant> findByIdAndStatusNot(Long id, String status);
}
